/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 文件解析情况
 *
 * @author hxloongs
 * @date 2024-8-15
 */
@AllArgsConstructor
@Getter
public enum FileParsingStatusEnum {
    EXIST(1, "该零组件已存在"),
    NOT_EXIST(2, "零组件不存在");
    private final Integer value;
    private final String desc;

    public static String getDescByValue(Integer value) {
        FileParsingStatusEnum fileParsingStatusEnum = forValue(value);
        if (fileParsingStatusEnum == null) {
            return null;
        }
        return fileParsingStatusEnum.getDesc();
    }

    public static FileParsingStatusEnum forValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (FileParsingStatusEnum fileParsingStatusEnum : FileParsingStatusEnum.values()) {
            if (fileParsingStatusEnum.getValue().equals(value)) {
                return fileParsingStatusEnum;
            }
        }
        return null;
    }

    public static FileParsingStatusEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (FileParsingStatusEnum fileParsingStatusEnum : FileParsingStatusEnum.values()) {
            if (desc.equals(fileParsingStatusEnum.getDesc())) {
                return fileParsingStatusEnum;
            }
        }
        return null;
    }
}
